﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int a = 0, b = 0, c = 0;//定义变量
        for (int i = 1; i < 100; i++)//遍历
        {
            Math.DivRem(i, 3, out a);//3行一列时取余 3人多一个
            Math.DivRem(i, 5, out b);//5行一列时取余 5人正好
            Math.DivRem(i, 7, out c);//7行一列时取余 7人一行少2个
            if (a == 1 && b == 0 && c == 5)//如果3种方式的余数符合要求
            {
                TextBox1.Text = i.ToString();//显示人数
                return;
            }
        }
    }
}
